﻿using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace BCVP.Net8.Service.Base
{
    public interface IBaseService<TEntity, TVo> where TEntity : class
    {
        ISqlSugarClient Db { get; }

        /// <summary>
        /// 添加一个
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        Task<long> Add(TEntity entity);
        
        /// <summary>
        /// 分表查询
        /// </summary>
        /// <param name="whereExpression"></param>
        /// <param name="orderByFields"></param>
        /// <returns></returns>
        Task<List<TEntity>> QuerySplit(Expression<Func<TEntity, bool>> whereExpression, string orderByFields = null);

        /// <summary>
        /// 写入实体数据
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        Task<List<long>> AddSplit(TEntity entity);

        /// <summary>
        /// 根据表达式查询信息
        /// </summary>
        /// <param name="whereExpression"></param>
        /// <returns></returns>
        Task<List<TVo>> Query(Expression<Func<TEntity, bool>>? whereExpression = null);
    }
}
